//
//  DeliveryWarehouseModel.swift
//  GreenDeal
//
//  Created by Moennig Q on 2023/5/10.
//

import UIKit
import HandyJSON
enum DeliveryWarehouseType: String {
    case OSW = "osw" //数据值
    case other = "other"
    case none = ""
}
class DeliveryWarehouseModel: HandyJSON {
    var id: Int = 0
    var address_text: String = ""
    var address_type: String = "" //对应DeliveryWarehouseValue 的rawvalue
    var unit_type: String = ""
    var unit_number: String = ""
    var street_number: String = ""
    var street_name: String = ""
    var street_type: String = ""
    var suburb: String = ""
    var state: String = ""
    var post_code: String = ""
    var default_storage: Bool = false
    var latitude: String = ""
    var longitude: String = ""
    var special_address: String = ""
    //导航用的地址：规则：//Street number空格Street name空格Street type, Suburb, State Postcode
    var map_full_address: String {//1.第一部分
        var resultString: String = ""
        if special_address != "" {//安装地址时，这里设置的是Special address
            resultString = special_address
        }else{
            //unit type
            if unit_type != ""  {
                resultString += unit_type + " "
            }
            //unit number
            if unit_number != "" {
                resultString += unit_number + " "
            }
            //street number
            if street_number != ""  {
                resultString += street_number + " "
            }
            //street name
            if street_name != "" {
                resultString += street_name + " "
            }
            //street type
            if street_type != ""{
                resultString += street_type
            }
            if resultString.count > 0 {
                resultString += ", "
            }
            //suburb
            if suburb != ""{
                resultString += suburb + ", "
            }
            //state
            if state != ""{
                resultString += state
            }
            //post code
            if post_code != ""{
                resultString += " " + post_code
            }
        }
        return resultString
    }

    required init() {
        
    }
}
